package com.exam.sacrifice.ui.adapter;

import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.exam.sacrifice.R;
import com.exam.sacrifice.ui.bean.RechargeInfo;

public class AddressListAdapter extends BaseQuickAdapter<RechargeInfo, BaseViewHolder> {

    private OnItemClickListener listener;

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        listener = onItemClickListener;
    }

    public AddressListAdapter() {
        super(R.layout.item_layout_address, null);
    }

    @Override
    protected void convert(BaseViewHolder helper, RechargeInfo item) {

        if (helper.getAdapterPosition() != 0) {
            helper.getView(R.id.tv_default).setVisibility(INVISIBLE);
            helper.getView(R.id.tv_rencent).setVisibility(INVISIBLE);
        } else {
            helper.getView(R.id.tv_default).setVisibility(VISIBLE);
            helper.getView(R.id.tv_rencent).setVisibility(VISIBLE);
        }
        helper.itemView.setOnClickListener(v -> {
            if (listener != null) {
                listener.onItemClick(item);
            }
        });
    }

    public interface OnItemClickListener {
        void onItemClick(RechargeInfo messageInfo);
    }
}
